//
//  ColumnsOfCollectionViewCell.m
//  UI_14_homework_UICollectionView
//
//  Created by li cheng on 16/8/2.
//  Copyright © 2016年 li cheng. All rights reserved.
//

#import "ColumnsOfCollectionViewCell.h"

@implementation ColumnsOfCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        _myImageView = [[UIImageView alloc] init];
        _myImageView.image = [UIImage imageNamed:@"0"];
        [self.contentView addSubview:_myImageView];
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.text = @"小满生活社";
        [self.contentView addSubview:_titleLabel];
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.text = @"更新至第28期";
        [self.contentView addSubview:_timeLabel];
        _autorLabel = [[UILabel alloc] init];
        _autorLabel.text = @"小满";
        [self.contentView addSubview:_autorLabel];
    }
    return self;
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    CGFloat halfWidth = CGRectGetWidth(self.contentView.bounds) / 2;
    CGFloat height = CGRectGetHeight(self.contentView.bounds);
    _myImageView.frame = CGRectMake(0, 0, halfWidth, height);
    _titleLabel.frame = CGRectMake(halfWidth, 0, halfWidth, height / 3);
    _timeLabel.frame = CGRectMake(halfWidth, height / 3, halfWidth, height / 3);
    _autorLabel.frame = CGRectMake(halfWidth, height / 3 * 2, halfWidth, height / 3);
}

@end
